home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Simulation / PDP-8 Simulator / Source Code / Assembler / Object.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-13  |  1.3 KB  |  67 lines  |  [TEXT/KAHL]

  1. /************************************************************
  2. *
  3. *
  4. *    Unit containing object code access functions.
  5. *
  6. *    by Adrian Bool in cooperation with Graham Cox.
  7. *
  8. *    copyright © phantasm coding 1992.
  9. *
  10. *
  11. ************************************************************/
  12.  
  13. #include "Global.h"
  14. #include "Object.h"
  15.  
  16. #include "Object.proto.h"
  17.  
  18. oHandle newObject(void)
  19.     {
  20.     oHandle    temp;
  21.     
  22.     temp = (oHandle) NewHandle(sizeof(object));
  23.     
  24.     if (temp != nil) 
  25.         {
  26.         (*temp)->version = 1;
  27.         (*temp)->startAddress = 0;
  28.         (*temp)->size = 0;
  29.         (*temp)->storage = nil;
  30.         (*temp)->position = 0;
  31.         }
  32.     return(temp);
  33.     }
  34.     
  35. void disposeObject(oHandle theObject)
  36.     {
  37.     if (theObject != nil)
  38.         {
  39.         if ((*theObject)->storage != nil)
  40.             DisposHandle((Handle) (*theObject)->storage);
  41.         
  42.         DisposHandle((Handle) theObject);
  43.         }
  44.     }
  45.     
  46. void createObjectSpace(oHandle theObject)
  47.     {
  48.     if (theObject != nil)
  49.         (*theObject)->storage = (oStHandle) NewHandle(sizeof(wordType)*(*theObject)->size);
  50.     else
  51.         AsmError = NotEnoughMemory;
  52.     }
  53.     
  54. void addBlock(oHandle theObject , rBlock theData , short size)
  55.     {
  56.     short x;
  57.     long offset;
  58.     
  59.     if(size > 255)
  60.         AsmError = BlockTooBig;
  61.     if (size > 0)
  62.         for(x = 0 ; x <= size-1 ; x++) 
  63.             {
  64.             offset = ((long) (*theObject)->position ) + x;
  65.             (*(*theObject)->storage)[offset] = theData[x];
  66.             }
  67.     }